//滚动区域的混合
export default (refValue)=>{
    return {
        mounted(){
            this.$refs[refValue].addEventListener('scroll',this.handleMainScroll);
            this.$bus.$on('setMainScroll',this.handleSetMainScroll);
        },
        beforeDestroyed(){
            this.$bus.$emit('mainScroll',undefined);
            this.$refs[refValue].removeEventListener('scroll',this.handleScroll);
            this.$bus.$off('setMainScroll',this.handleSetMainScroll);
        },
        methods:{
            handleMainScroll(){
                this.$bus.$emit('mainScroll',this.$refs[refValue]);
            },
            handleSetMainScroll(scrollTop){
                this.$refs[refValue].scrollTop = scrollTop;
            }
        }
    }
}